WORKROOT=/Users/xiaowei/program


CXX=g++
INCPATH=-I$(WORKROOT)/include -I$(WORKROOT)/include/boost-1_35/ -I$(WORKROOT)/include/thrift
CXXFLAGS=-g
LIBS=-L$(WORKROOT)/lib -lgtest
MAKDEP=Makefile.dep

TARGET=libxdragonball.a

RPC=xdragonball.idl
GEN=gen-cpp

.cpp.o:
	$(CXX) -c -o $@ $<  $(CXXFLAGS) $(CPPFLAGS) $(INCPATH)

all : $(TARGET)

rpc : $(RPC)
	thrift --gen cpp $^

SRC=$(wildcard xdb_*.cpp gen-cpp/*.cpp)
OBJS=$(SRC:.cpp=.o)

-include $(MAKDEP)

$(TARGET) : $(OBJS)
	ar cr $@ $^
	ranlib $@

$(MAKDEP):$(SRC)
	-$(CC) -MG -MM $(CPPFLAGS) $(INCPATH) $^ > $@

clean:
	rm -rf $(OBJS) $(TARGET)
	rm -rf test_config test_config.conf.*
	rm -rf $(GEN)

test: test_config $(TARGET)

test_config : test_config.cpp $(TARGET)
	$(CXX) -o $@ $< $(INCPATH) $(LIBS) $(TARGET) $(CXXFLAGS)

run : test
	./test_config
